package com.ruoyi.web.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TrafficInfo;
import com.ruoyi.system.service.ITrafficInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 交通信息Controller
 * 
 * @author ruoyi
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/system/TrafficInfo")
public class TrafficInfoController extends BaseController
{
    @Autowired
    private ITrafficInfoService trafficInfoService;

    /**
     * 查询交通信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:TrafficInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TrafficInfo trafficInfo)
    {
        startPage();
        List<TrafficInfo> list = trafficInfoService.selectTrafficInfoList(trafficInfo);
        return getDataTable(list);
    }

    /**
     * 导出交通信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:TrafficInfo:export')")
    @Log(title = "交通信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrafficInfo trafficInfo)
    {
        List<TrafficInfo> list = trafficInfoService.selectTrafficInfoList(trafficInfo);
        ExcelUtil<TrafficInfo> util = new ExcelUtil<TrafficInfo>(TrafficInfo.class);
        util.exportExcel(response, list, "交通信息数据");
    }

    /**
     * 获取交通信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:TrafficInfo:query')")
    @GetMapping(value = "/{trafficId}")
    public AjaxResult getInfo(@PathVariable("trafficId") Long trafficId)
    {
        return success(trafficInfoService.selectTrafficInfoByTrafficId(trafficId));
    }

    /**
     * 新增交通信息
     */
    @PreAuthorize("@ss.hasPermi('system:TrafficInfo:add')")
    @Log(title = "交通信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrafficInfo trafficInfo)
    {
        return toAjax(trafficInfoService.insertTrafficInfo(trafficInfo));
    }

    /**
     * 修改交通信息
     */
    @PreAuthorize("@ss.hasPermi('system:TrafficInfo:edit')")
    @Log(title = "交通信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrafficInfo trafficInfo)
    {
        return toAjax(trafficInfoService.updateTrafficInfo(trafficInfo));
    }

    /**
     * 删除交通信息
     */
    @PreAuthorize("@ss.hasPermi('system:TrafficInfo:remove')")
    @Log(title = "交通信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trafficIds}")
    public AjaxResult remove(@PathVariable Long[] trafficIds)
    {
        return toAjax(trafficInfoService.deleteTrafficInfoByTrafficIds(trafficIds));
    }
}
